import unittest
import pymysql
import requests
from parameterized import parameterized
from api.ihrm_zsgc import ihrmzsgc
from common.assert_util import common_assert
from common.get_headers import get_headers
from common.mobile import MOBILE
from common.pymsql import DBUtil
from common.read import get_list
from scripts.config import EMP_ID


class Testzsgc(unittest.TestCase):
    @parameterized.expand(get_list())
    def test_zengjia(self,json_data,status_code,success,code,message):
        sql = f"delete from bs_user where mobile = '{MOBILE}';"
        DBUtil.uid(sql)
        # json_data = {"username":"张三的",
        #              "mobile":"15678859455",
        #              "workNumber":"34239466"}
        resp = ihrmzsgc.insert(json_data)
        # common_assert(self,resp,200,True,10000,"操作成功")
        common_assert(self, resp, status_code,success,code, message)
        sql = f"delete from bs_user where mobile = '{MOBILE}';"

    # def test_gai(self):
    #     # 获取令牌
    #     headers = get_headers()
    #     # sql语句
    #     sql = "insert into bs_user(id,username,mobile,work_number) values('13123124','张六','13456789014','124235347457');"
    #     # 调用添加方法
    #     DBUtil.uid(sql)
    #     # 发请求:
    #     resp = requests.put(url = "http://ihrm2-test.itheima.net/api/sys/user/13123124",
    #                         headers=headers,
    #                         json={"username":"找死"})
    #     # 断言
    #     common_assert(self,resp,200,True,10000,"操作成功")

    @parameterized.expand(get_list())
    def test_gai(self,json_data,status_code,success,code,message):
        # 获取令牌
        headers = get_headers()
        # sql语句
        # sql = "insert into bs_user(id,username,mobile,work_number) values('13123124','张六','13456789014','124235347457');"
        sql = f"insert into bs_user(id,username,mobile,work_number) values('{EMP_ID}');"
        # 调用添加方法
        DBUtil.uid(sql)
        # 发请求
        # resp = requests.put(url = "http://ihrm2-test.itheima.net/api/sys/user/13123124",
        #                     headers=headers,
        #                     json={"username":"找死"})
        resp = ihrmzsgc().gai(89124354,json)
        # 调用断言
        common_assert(self,resp,status_code,success,code,message)



